package ooday03;

public class RefArrayDemo {
    public static void main(String[] args) {
        Dog[] dogs = new Dog[3];
        dogs[0] = new Dog("小黑",2,"黑");
        dogs[1] = new Dog("小白",1,"白");
        dogs[2] = new Dog("小黄",1,"黄");
        for (int i=0;i<dogs.length;i++){
            System.out.println(dogs[i].name);
            dogs[i].eat();
        }

        Chick[] chicks = new Chick[1];
        chicks[0] = new Chick("小花",1,"花");
        //chicks[1] = new Chick("大花",2,"花");
        for (int i=0;i< chicks.length;i++){
            System.out.println(chicks[i].name);
            chicks[i].layEggs();
        }

        Fish[] fish = new Fish[1];
        fish[0] = new Fish("小金",1,"金");
        fish[1] =new Fish("小红",1,"红");
        for (int i=0;i< fish.length;i++){
            System.out.println(fish[i].color);
            fish[i].swim();
        }








        /*Dog[] dogs = new Dog[5];
        Chick[] chicks = new Chick[2];
        Fish[] fish = new Fish[1];
        for (int i = 0;i <dogs.length;i++){
            System.out.println(dogs[i]);
        }
         */
    }
}
